home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / bsrc_250.zip / MAILOVLY.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  33KB  |  1,192 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*                 This module was written by Bob Hartman                   */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*                   BinkleyTerm Mail Control Routines                      */
  17. /*                                                                          */
  18. /*                                                                          */
  19. /*    For complete  details  of the licensing restrictions, please refer    */
  20. /*    to the License  agreement,  which  is published in its entirety in    */
  21. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  22. /*                                                                          */
  23. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  24. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  25. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  26. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  27. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  28. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  29. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  30. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  31. /*                                                                          */
  32. /*                                                                          */
  33. /* You can contact Bit Bucket Software Co. at any one of the following      */
  34. /* addresses:                                                               */
  35. /*                                                                          */
  36. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  37. /* P.O. Box 460398                AlterNet 7:491/0                          */
  38. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  39. /*                                Internet f491.n343.z1.fidonet.org         */
  40. /*                                                                          */
  41. /* Please feel free to contact us at any time to share your comments about  */
  42. /* our software and/or licensing policies.                                  */
  43. /*                                                                          */
  44. /*--------------------------------------------------------------------------*/
  45.  
  46. /* Include this file before any other includes or defines! */
  47.  
  48. #include "includes.h"
  49.  
  50. char mail_stat (MAILP);
  51. int xmit_install (MAILP, ADDRP);
  52. MAILP xmit_find (MAILP, ADDRP);
  53. long netsize (MAILP);
  54. int any_mail (MAILP);
  55. void do_xmit_line (char *, MAILP);
  56. void xmit_sort (void);
  57. char *numdisp (long);
  58.  
  59. #ifdef MILQ
  60. static char *HoldFmtStr = "%16.16s %4.4s %5.5s %c";
  61. static char *HoldNoSize = "%21.21s %5.5s %c";
  62. #else
  63. static char *HoldFmtStr = "%-16.16s %4.4s %5.5s %c";
  64. static char *HoldNoSize = "%-21.21s %5.5s %c";
  65. #endif
  66.  
  67. void xmit_sameplace ()
  68. {
  69.    MAILP p, p1;
  70.  
  71.    /* Find the guy we just gave mail to */
  72.    p = find_mail (&remote_addr);
  73.    remote_addr.Zone = remote_addr.Net = remote_addr.Node = remote_addr.Point = 0;
  74.    remote_addr.Domain = NULL;
  75.    if (p == NULL)
  76.       {
  77.       /* He is not there */
  78.       return;
  79.       }
  80.  
  81.    /* Save our current pointer */
  82.    p1 = next_mail;
  83.    if (p != next_mail)
  84.       {
  85.       /* If it is not the one we just gave mail to, save ptr and delete */
  86.       next_mail = p;
  87.       xmit_delete ();
  88.       next_mail = p1;
  89.       }
  90.    else
  91.       {
  92.       /* It was the guy at the head of the list, so just delete him */
  93.       xmit_delete ();
  94.       }
  95.  
  96.    /* If we came in with a null, leave with a null */
  97.    if (p1 == NULL)
  98.       next_mail = NULL;
  99.  
  100.    return;
  101. }
  102.  
  103. MAILP find_mail (ADDRP address)
  104. {
  105.    MAILP p;
  106.  
  107.    p = mail_top;
  108.    while (p != NULL)
  109.       {
  110.       if ((no_zones || (p->mail_addr.Zone == address->Zone)) &&
  111.           (p->mail_addr.Net == address->Net) &&
  112.           (p->mail_addr.Node == address->Node) &&
  113.           (p->mail_addr.Point == address->Point) &&
  114.           ((p->mail_addr.Domain == address->Domain) ||
  115.            ((p->mail_addr.Domain == my_addr.Domain) &&
  116.             (address->Domain == NULL))))
  117.          break;
  118.       p = p->next;
  119.       }
  120.  
  121.    return (p);
  122. }
  123.  
  124. int xmit_install (MAILP p, ADDRP addr)
  125. {
  126.    MAILP p1, p2;
  127.    int rettype;
  128.    long sztemp;
  129.  
  130.    p2 = find_mail (addr);
  131.  
  132.    if (p2 == NULL)
  133.       {
  134.       /* We didn't find it in what we have already */
  135.       p1 = p;
  136.       p1->mail_addr = *addr;
  137.       rettype = 0;
  138.       }
  139.    else
  140.       {
  141.       /* We found it, so we have to make sure the higher level routine knows */
  142.       p1 = p2;
  143.       rettype = 1;
  144.       }
  145.  
  146. /*
  147.  * Get the size of the entry. If it's a FLO-type file,
  148.  * call netsize to find out how big the stuff contained in it
  149.  * actually is. If it's a packet, just take its size.
  150.  *
  151.  * Hold packets don't count.
  152.  */
  153.  
  154.    if (!no_size)
  155.       {
  156.       sztemp = 0L;
  157.  
  158.       if (!strncmp (&(dta_str.name[10]), "LO", 2))
  159.          p1->mailsize += (sztemp = netsize (p1));
  160.  
  161.       else
  162.       if (!strncmp (&(dta_str.name[10]), "UT", 2))
  163.          p1->mailsize += (sztemp = dta_str.size);
  164.  
  165.       if (dta_str.name[9] != 'H')
  166.          p1->callsize += sztemp;
  167.       }
  168.  
  169.    switch (dta_str.name[9])
  170.       {
  171.       case 'C':      /* Crash */
  172.          p1->mailtypes |= MAIL_CRASH;
  173.          break;
  174.  
  175.       case 'H':      /* Hold */
  176.          p1->mailtypes |= MAIL_HOLD;
  177.          break;
  178.  
  179.       case 'F':      /* Normal */
  180.       case 'O':
  181.          p1->mailtypes |= MAIL_NORMAL;
  182.          break;
  183.  
  184.       case 'D':      /* Direct */
  185.          p1->mailtypes |= MAIL_DIRECT;
  186.          break;
  187.  
  188.       case 'R':      /* Request */
  189.          p1->mailtypes |= MAIL_REQUEST;
  190.          break;
  191.       }
  192.  
  193.    if (!nodefind (&(p1->mail_addr), 0))
  194.       {
  195.       p1->mailtypes |= MAIL_UNKNOWN;
  196.       return (rettype);
  197.       }
  198.  
  199.    /* Don't call for "HOLD" or "REQ" stuff. */
  200.    if ((dta_str.name[9] == 'H') || (dta_str.name[9] == 'R'))
  201.       {
  202.       return (rettype);
  203.       }
  204.  
  205.    /* If there's no event, set mail to 'go' */
  206.    if (cur_event < 0)
  207.       {
  208.       p1->mailtypes &= ~MAIL_QSMALL;
  209.       p1->mailtypes |= MAIL_WILLGO;
  210.       return (rettype);
  211.       }
  212.  
  213.    /* If it is a crash only event and we have crashmail, set it to go */
  214.  
  215.    if (e_ptrs[cur_event].behavior & MAT_HIPRICM)
  216.       {
  217.       if ((dta_str.name[9] == 'C') && (newnodedes.NodeFlags & B_CM))
  218.          {
  219.          p1->mailtypes &= ~MAIL_QSMALL;
  220.          p1->mailtypes |= MAIL_WILLGO;
  221.          return (rettype);
  222.          }
  223.       }
  224.  
  225.    /* If it is a crash only event and this wasn't crash, return */
  226.    if ((dta_str.name[9] != 'C') && (e_ptrs[cur_event].behavior & MAT_CM))
  227.       {
  228.       return (rettype);
  229.       }
  230.  
  231.    /* Is this a local only event? */
  232.    if (e_ptrs[cur_event].behavior & MAT_LOCAL)
  233.       {
  234.       /*
  235.        * If this is supposed to be only local, then get out if it isn't 
  236.        */
  237.       if (e_ptrs[cur_event].node_cost >= 0)
  238.